package com.cssw.fyzb.busi.util;

import com.cssw.fyzb.core.util.StringUtil;

/**
 * @Author: yangyiqun
 * @Date: 2020/10/10 12:06
 */
public class EncryptUtil {

    // 手机号码前三后四脱敏
    public static String mobileEncrypt(String mobile) {
        if (StringUtil.isEmpty(mobile) || (mobile.length() != 11)) {
            return mobile;
        }

        return mobile.substring(0,3) + "****" + mobile.substring(7);
    }

    //身份证前三后四脱敏
    public static String idEncrypt(String id) {
        if (StringUtil.isEmpty(id) || (id.length() < 8)) {
            return id;
        }

        return id.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
    }

}
